package com.collection;

import java.util.WeakHashMap;

/**
 * A键为弱类型，gc运行立即回收
 *
 * @author jiangbang
 * @date 2016/5/31
 */
public class WeakHashMapDemo {

    public static void main(String[] args) {
        WeakHashMap<String,String> map = new WeakHashMap<String,String>();
        //常量池不被回收
        map.put("abc","a");
        map.put("12","a");
         map.put(new String("bsd"),"a");
        map.put(new String("123"),"a");
        //通知回收
        System.gc();
        System.runFinalization();
        System.out.println(map);
    }
}
